/*
显示游戏公告
*/

layui.define(['cosjs','scene'], function (exports) {
    let $ = layui.jquery,scene = layui.scene;
    let index = 0,articleKeys;
    function article() {
        let config =  scene.gamesdk.game.config(1);
        articleKeys = Object.keys(config);
        if(index >= articleKeys.length){
            return Promise.reject('config not exist')
        }
        let id = articleKeys[index];
        index ++;
        return config[id];
    }

    article.dialog = function () {
        if(index >= articleKeys.length){
            index = 0;
            return false;
        }
        let opts = {};
        opts['end'] = function(){
            scene.dialog('game/article');
        }
        return opts;
    }

    exports('game/article', article);
})